//
//  TPCasesCell.m
//  Yimei
//
//  Created by xiaowu xiaowu on 2017/10/23.
//  Copyright © 2017年 xiaowu xiaowu. All rights reserved.
//

#import "TPCasesCell.h"
#import "TPHomeModel.h"
@implementation TPCasesCell
@synthesize indexPath = _indexPath;
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setup];
    }
    return self;
}
-(instancetype)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        [self setup];
    }
    return self;
}
-(void)setup{
    
    self.backgroundColor = [UIColor whiteColor];
    self.price_label.font = self.detail_label.font = fontSystemOfSize(13);
    self.price_label.textColor = self.detail_label.textColor = TPAllBackgroundColor;
    self.title_label.font = fontSystemOfSize(15);
    self.title_label.numberOfLines = 2;
    self.detail_label.textAlignment = NSTextAlignmentRight;
    self.image_view.contentMode = UIViewContentModeScaleAspectFill;
    
    [self.price_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(2.0f);
        make.bottom.mas_equalTo(0.0);
        make.height.mas_equalTo(23.0);
    }];
    [self.detail_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-6.0);
        make.bottom.mas_equalTo(0.0);
        make.height.mas_equalTo(self.price_label.mas_height);
        make.left.mas_equalTo(self.price_label.mas_right);
    }];
    
    [self.title_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.detail_label.mas_top).offset(-5.0);
        make.height.mas_lessThanOrEqualTo(30.0);
        make.height.mas_greaterThanOrEqualTo(44);
        make.left.mas_equalTo(self.price_label.mas_left);
        make.right.mas_equalTo(self.detail_label.mas_right);
    }];
    
    [self.image_view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0.0);
        make.left.right.mas_equalTo(0.0);
        make.bottom.mas_equalTo(self.title_label.mas_top);
    }];
    
    //    self.title_label.textAlignment = NSTextAlignmentCenter;
}
-(void)setIndexPath:(NSIndexPath *)indexPath{
    _indexPath = indexPath;
}

-(void)setModel:(TPHomeModel *)model{
    
    [self.image_view ym_setImageWithURL:model.goods_image placeholderImage:defaultLogo];
    self.title_label.text = model.goods_name;
    self.price_label.text = [NSString stringWithFormat:@"￥%@",model.goods_price];
    self.detail_label.text = [NSString stringWithFormat:@"已预约:%ld",model.appoint_number];
    
}

@end
